﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq.Expressions;

namespace Kkc.Application.Specifications
{
    public class NotSpecification<T>: UnarySpecification<T>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NotSpecification&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="specification">The specification.</param>
        public NotSpecification(ISpecification<T> specification)
            : base(specification)
        {
        }

        protected override Expression<Func<T, bool>> CreateUnaryExpression(Expression<Func<T, bool>> nestedExpression)
        {
            return System.Linq.Expressions.Expression.Lambda<Func<T, bool>>(System.Linq.Expressions.Expression.Not(nestedExpression.Body), nestedExpression.Parameters);
        }
    }
}